﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;

public partial class product1 : System.Web.UI.Page
{
    protected void Page_Load(object sender, EventArgs e)
    {

    }
    protected void Button1_Click(object sender, EventArgs e)
    {
        
        DataClassesDataContext a1 = new DataClassesDataContext();
        int? i;
        i = a1.login((String)Session["phone"], (String)Session["phone"], (String)Session["psw"]);
        if (i == 1)
        {   
            
            string shop_sign = (FormView1.FindControl("shop_signLabel") as Label).Text; 
            //System.Web.UI.WebControls.Label xh = (System.Web.UI.WebControls.Label)FormView1.FindControl("shop_signLebel");
            string num = (FormView1.FindControl("TextBox1") as TextBox).Text;
            int unm1=Convert.ToInt32(num);
            //Response.Write(num);
            i=a1.select_cart((String)Session["phone"], shop_sign);
            if (i == 0)
            {
                a1.insert_cart((String)Session["phone"], shop_sign, unm1);
                Response.Write("<script>alert('添加成功！')</script>");
                Response.Redirect("~/a4(购物车).aspx");
            }
            else 
            {
                a1.update_cart((String)Session["phone"], shop_sign, unm1);
                Response.Write("<script>alert('添加成功！')</script>");
                Response.Redirect("~/a4(购物车).aspx");
            }
            
        }
        else
        {
            Response.Write("<script>alert('请先登录！')</script>");
        }
    
    }
    protected void FormView1_PageIndexChanging(object sender, FormViewPageEventArgs e)
    {
       
    }
}